package com.hsp.homework;

public class Homework01 {
    public static void main(String[] args) {
        Person person = new Person("jack", 23, "manager");
        Person person1 = new Person("lucy", 20, "worker");
        Person person2 = new Person("mack", 34, "cooker");
        Person person3 = new Person("jj", 22, "washer");
//        System.out.println(person.getAge());
//        int[] ageNum = {person.getAge(),person1.getAge(),person2.getAge()};
        Person[] per ={person,person1,person2,person3};
        Person temp ;
        for (int i = 0; i < per.length-1; i++) {
            for (int j = 0; j < per.length-i-1; j++) {
                if(per[j].getAge()>per[j+1].getAge()){
                    temp = per[j];
                    per[j] = per[j+1];
                    per[j+1] = temp;
            }


            }
        }
        for (int i = 0; i < per.length; i++) {
            System.out.print(per[i]+"\n");
        }

    }
}
class Person{
   private String name;
   private int age;
   private String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", job='" + job + '\'' +
                '}';
    }
}